USE Liberty
GO
-- ------------------------------------------------------------------------------------------------
-- ServiceMen	(MilitaryPersonnel ???)
-- ------------------------------------------------------------------------------------------------
SET NOCOUNT OFF
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
SET ARITHABORT ON
SET CONCAT_NULL_YIELDS_NULL ON
SET QUOTED_IDENTIFIER ON
SET NUMERIC_ROUNDABORT OFF
GO

PRINT 'Creating Table dbo.ServiceMen...'
GO

IF OBJECT_ID('dbo.ServiceMen', 'U') IS NULL
BEGIN
	CREATE TABLE dbo.ServiceMen
	(OID				bigint						NOT NULL
	,Version			rowversion
	,PrimaryAddressID	bigint						NOT NULL
	,PermanentAddressID	bigint						NOT NULL

	,UpdatedDate		datetime					NOT NULL
		CONSTRAINT DFLT_ServiceMen_UpdatedDate DEFAULT GETDATE()
	,CreatedDate		datetime					NOT NULL
		CONSTRAINT DFLT_ServiceMen_CreatedDate DEFAULT GETDATE()

	,CONSTRAINT PK_ServiceMen PRIMARY KEY CLUSTERED( OID ) --ON PRIMARY

	,CONSTRAINT FK_ServiceMen_People FOREIGN KEY (OID)
		REFERENCES People(OID)

	,CONSTRAINT FK_ServiceMen_Addresses1 FOREIGN KEY (PrimaryAddressID)
		REFERENCES Addresses(OID)

	,CONSTRAINT FK_ServiceMen_Addresses2 FOREIGN KEY (PermanentAddressID)
		REFERENCES Addresses(OID)


	)

	PRINT 'Table dbo.ServiceMen has been created successfully.'

END
ELSE 
BEGIN
    PRINT 'Table dbo.ServiceMen already exists.'
END

GO
